<template>
  <div
    class="navbar"
    v-if="
      compData.navbar.mode == 'normal' ||
      (compData.navbar.mode == 'inner' && compData.navbar.alwaysShow) ||
      isScroll
    "
  >
    <div class="navbar-wrap">
      <div
          v-if="props.templateDetailType == 'diypage'"
          class="item"
          :style="{ width: scale + 'px', height: 32 + 'px', top: 0 + 'px', left: 0 + 'px' }"
        >
        <img class="header-diypage" src="/static/images/shop/decorate/header-diypage.png" />
      </div>
      <template v-for="l in compData.navbar.list[pType]" :key="l">
        <div
          class="item"
          :style="{
            width: l.width * scale + 'px',
            height: 32 + 'px',
            top: 0 + 'px',
            left: l.left * scale + 'px',
          }"
        >
          <div v-if="l.type == 'text'" class="text sa-line-1" :style="{ color: l.textColor }">
            {{ l.text }}
          </div>
          <sa-image v-if="l.type == 'image'" :url="l.src" :size="20" :suffix="null"></sa-image>
          <div
            v-if="l.type == 'search'"
            class="search sa-line-1"
            :style="{ borderRadius: l.borderRadius + 'px' }"
          >
            <el-icon class="sa-m-r-8"><Search /></el-icon>
            {{ l.placeholder }}
          </div>
		  <div  class="btn" v-if="l.type == 'search'&& l?.showBtn == 1 && (l.width >= 3)" :style="{
				borderRadius: l?.btnBorderRadius + 'px' ,
				color: l?.btnTextColol,
				background: l?.btnBgColol,
			}">
			搜索
		  </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script setup>
  import { computed } from 'vue';

  const props = defineProps(['compData', 'platformType', 'isScroll', 'templateDetailType']);

  const scale = (375 - 12) / 8;

  const pType = computed(() => (props.platformType == 'WechatMiniProgram' ? 'mp' : 'app'));
</script>

<style lang="scss" scoped>
  .navbar {
    padding: 9px 6px;
    width: 100%;
    .header-diypage {
      width: 100%;
    }
    .navbar-wrap {
      width: inherit;
      height: 32px;
      position: relative;
      .item {
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .text {
        height: 32px;
        line-height: 32px;
        font-size: 16px;
      }
      .search {
        width: 100%;
        height: 32px;
        line-height: 32px;
        border: 1px solid #eee;
        padding: 0 10px;
        font-size: 12px;
        color: var(--sa-font);
        background: #fff;
      }
	  .btn {
        width: 50px;
        min-width: 50px;
        height: 32px;
        line-height: 32px;
        font-size: 12px;
        color: var(--sa-font);
		text-align: center;
		margin-left: 8px;
        background: #fff;
      }
    }
  }
</style>
